﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// Summary description for QuanLiUser
/// </summary>
public class QuanLiUser
{
	public QuanLiUser()
	{
		//
		// TODO: Add constructor logic here
		//

	}
    string error = "";
    AccessData access = new AccessData();
    //them 1 user moi
    public int Insert_User(string username,string password,int quyen,string fullname,string email,int status,string date)
    {
        int i = -1;
        try
        {
            SqlConnection connection = access.GetConnect();
            connection.Open();
            SqlCommand cmd = new SqlCommand("sp_ThemUser", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = username;
            cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = password;
            cmd.Parameters.Add("@rolecode", SqlDbType.Int).Value = quyen;
            cmd.Parameters.Add("@fullname", SqlDbType.NVarChar).Value = fullname;
            cmd.Parameters.Add("@email", SqlDbType.VarChar).Value = email;
            cmd.Parameters.Add("@status", SqlDbType.Int).Value = status;
            cmd.Parameters.Add("@date", SqlDbType.VarChar).Value = date;
            i=cmd.ExecuteNonQuery();

            cmd.Dispose();

            connection.Close();
        }
        catch (SqlException Ex)
        {
            error = Ex.Message;
            return i;
        }

        return i;
    }
}